package Renderer.HTMLDrawer;
import Tree.Node;
import Renderer.*;

/**
 * This class processes all Link tag Nodes.
 * @author Nathan Scully
 * @version FINAL
 */
public class Link extends Drawer
{
    /**
     * The Constuctor for this class, which calls the Drawer superclass and
     * passes the node and renderer to it.
     * @param node The Node to be passed to Drawer.
     * @param renderer The Renderer to be passed to Drawer.
     */
    public Link(Node node, HTMLRenderer renderer)
    {
        super(node, renderer);
    }

    /**
     * The overwritten draw method. This creates a clone of the current TextProperty
     * object and updates it with the new font options that are typical of a link.
     * The TextProperty object will also hold the link address.
     * This new TextProperty object is then pushed onto the Stack.
     */
    public void draw()
    {
        TextProperty textProperty = (TextProperty)(stack.peek().clone());
        textProperty.setUnderlined(true);
        textProperty.setColor("blue");
        textProperty.setLink(true, ((HTMLParser.HTMLTag.Link)node).getLink());
        stack.Push(textProperty);
    }

    /**
     * The overwritten postProcess method. When a close Link tag is found, this
     * will remove the TextPropery object that was created in draw() from the
     * Stack, effectively undoing what draw() did.
     */
    public void postProcess()
    {
        stack.pop();
    }
}
